<script setup>
  import { noticeStore } from '@/store/modules/notice'
  import { websocketInstance } from '@/utils/socket'

  const { noticeList } = storeToRefs(noticeStore())

  nextTick(() => {})

  onMounted(() => {
    websocketInstance(() => {
      //
    })
  })
  const activeName = ref('notice')
  const handleClick = () => {}
</script>

<template>
  <el-badge type="danger" :value="(noticeList && noticeList.length) || ''">
    <el-popover placement="bottom" trigger="hover" :width="300">
      <template #reference>
        <vab-icon icon="notification-line" />
      </template>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="公告" name="notice">
          <div class="notice-list">
            <el-scrollbar>
              <ul>
                <li v-for="(item, index) in noticeList" :key="index">
                  <!-- <el-avatar :size="45" :src="item.image" /> -->
                  <span v-html="item.showInfo" />
                </li>
              </ul>
            </el-scrollbar>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-popover>
  </el-badge>
</template>

<style lang="scss" scoped>
  :deep() {
    .el-tabs__active-bar {
      min-width: 28px;
    }
  }

  .notice-list {
    height: 29vh;

    ul {
      padding: 0 15px 0 0;
      margin: 0;

      li {
        display: flex;
        align-items: center;
        padding: 10px 0 10px 0;

        :deep() {
          .el-avatar {
            flex-shrink: 0;
            width: 50px;
            height: 50px;
            border-radius: 50%;
          }
        }

        span {
          margin-left: 10px;
        }
      }
    }
  }

  .notice-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0 0 0;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    border-top: 1px solid #e8eaec;

    i {
      margin-right: 3px;
    }
  }
</style>
